home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / yase.arc / GROUP3.ASM < prev    next >
Assembly Source File  |  1986-12-13  |  7KB  |  206 lines

  1. ******************************************************************
  2. * COPYRIGHT (C) 1986 by Donald Krantz and James Stanley
  3. * - Note: This is a real, live, actual, registered copyright,
  4. *   and should be treated as such. This source code is from
  5. *   the book "68000 Assembly Language", Krantz and Stanley,
  6. *   Addison-Wesley Publishing Company, Reading, MA, 1986.
  7. *   Permission granted by the authors for non-commercial use
  8. *   in programs released to the public domain, as long as this
  9. *   copyright notice remains attached and visible.
  10. *
  11. *****************************************************************
  12. * GROUP 3 (WIndowing) Commands
  13.  
  14.     xref    get_buf,prompt,prtscr,sync_cur,case,cursor
  15.     xref     _getkey,cls,cmd_w,border_w,used,set_w,open_w
  16.     xdef    g_3,refresh
  17.  
  18. #edit.h
  19. #cursor.h
  20.  
  21. *****************************************************************
  22. * G_3 - Group 3 (window) commands processor
  23. g_3:
  24.     move.l    #w_cmd,a0    * load prompt string address
  25.     bsr    prompt        * output prompt
  26.     bsr    _getkey        * get switch key
  27.     and.w    #$001F,d0    * make u/l case into ctrl char
  28.     move.l    #table3,a0    * setup case switch table
  29.     bsr    case        * process choices
  30.     rts            * resume editing
  31. w_cmd:    dc.b    'Window Commands: P R E X',0
  32.     dc.w    0
  33. *****************************************************************
  34. * TABLE3 - switch table for group 3 (window) commands
  35. table3:
  36.     dc.w    4        * four choices
  37.     dc.w    $10        * ^P - pop new window
  38.     dc.l    pop
  39.     dc.w    $12        * ^R - rotate windows
  40.     dc.l    rotate
  41.     dc.w    c_up        * move UL corner of window
  42.     dc.l    upleft
  43.     dc.w    c_down        * move LR corner of window
  44.     dc.l    lowright
  45.     dc.l    default        * "others" choice
  46. default:
  47.     rts
  48. *****************************************************************
  49. * UPLEFT - Moves the upper left corner of the active window
  50. upleft:
  51.     lea    w_ulbx(a5),a2    * pointer to X left side
  52.     lea    w_ulby(a5),a1    * pointer to Y top
  53.     move.w    #lim_lx,d1    * X left limit
  54.     move.w    w_lrbx(a5),d2    * X right limit
  55.     sub.w    #12,d2        * must be at least 10 chars wide
  56.     move.w    #lim_uy,d5    * Y top limit
  57.     move.w    w_lrby(a5),d4    * Y bottom limit
  58.     sub.w    #2,d4        * must be at least 3 high
  59.     bsr    mover        * use common code
  60.     bsr    refresh        * have to remake screen
  61.     rts
  62. *****************************************************************
  63. * LOWRIGHT - moves the lower right corner of the window
  64. lowright:
  65.     lea    w_lrbx(a5),a2    * pointer to X right side
  66.     lea    w_lrby(a5),a1    * pointer to Y bottom
  67.     move.w    #lim_rx,d2    * X right limit
  68.     move.w    w_ulbx(a5),d1    * X left limit
  69.     add.w    #12,d1        * must be at least 10 chars wide
  70.     move.w    #lim_ly,d4    * Y bottom limit
  71.     move.w    w_ulby(a5),d5    * Y top limit
  72.     add.w    #2,d5        * must be at least 3 high
  73.     bsr    mover        * use common code
  74.     bsr    refresh        * have to remake screen
  75.     rts
  76. *****************************************************************
  77. * MOVER - moves the window corners around
  78. mover:
  79.     move.w    (a1),-(a7)    * push cursor Y
  80.     move.w    (a2),-(a7)    * push cursor X
  81.     bsr    cursor        * move cursor to window corner
  82.     addq.l    #4,a7        * adjust stack
  83.     bsr    sync_curs    * make sure cursor moves
  84.     bsr    _getkey        * go see what human has in mind
  85.     move.l    #mtable,a0    * get case switch table ready
  86.     bra    case        * do what human wants... maybe.
  87. *****************************************************************
  88. * MTABLE - window streching case dispatch table
  89. mtable:
  90.     dc.w    9        * 9 choices for this case
  91.     dc.w    c_up        * cursor up
  92.     dc.l    oneup
  93.     dc.w    c_down        * cursor down
  94.     dc.l    onedn
  95.     dc.w    c_right        * cursor right
  96.     dc.l    onert
  97.     dc.w    c_left        * cursor left
  98.     dc.l    onelf
  99.     dc.w    page_up        * max up
  100.     dc.l    allup
  101.     dc.w    page_down    * max down
  102.     dc.l    alldn
  103.     dc.w    c_w_right    * max right
  104.     dc.l    allrt
  105.     dc.w    c_w_left    * max left
  106.     dc.l    alllf
  107.     dc.w    return        * mods complete
  108.     dc.l    done
  109.     dc.l    mover        * default case (no action)
  110. *****************************************************************
  111. oneup:
  112.     cmp.w    (a1),d5        * check top limit
  113.     beq    mover        * branch on limit
  114.     sub.w    #1,(a1)        * move up one line
  115.     bra    mover
  116. *****************************************************************
  117. onedn:
  118.     cmp.w    (a1),d4        * check bottom limit
  119.     beq    mover        * branch on limit
  120.     addq.w    #1,(a1)        * move down one line
  121.     bra    mover
  122. *****************************************************************
  123. onert:
  124.     cmp.w    (a2),d2        * check right limit
  125.     beq    mover        * branch on limit
  126.     addq.w    #1,(a2)        * move one char right
  127.     bra    mover
  128. *****************************************************************
  129. onelf:
  130.     cmp.w    (a2),d1        * check left limit
  131.     beq    mover        * branch on limit
  132.     subq.w    #1,(a2)        * move left one char
  133.     bra    mover
  134. *****************************************************************
  135. allup:
  136.     move.w    d5,(a1)        * set to upper limit
  137.     bra    mover
  138. *****************************************************************
  139. alldn:
  140.     move.w    d4,(a1)        * set to lower limit
  141.     bra    mover
  142. *****************************************************************
  143. alllf:
  144.     move.w    d1,(a2)        * set to left limit
  145.     bra    mover
  146. *****************************************************************
  147. allrt:
  148.     move.w    d2,(a2)        * set to right limit
  149.     bra    mover
  150. *****************************************************************
  151. done:
  152.     move.w    w_ulbx(a5),d0    * reset window params
  153.     move.w    w_ulby(a5),d1    
  154.     move.w    w_lrbx(a5),d2
  155.     move.w    w_lrby(a5),d3
  156.     bsr    set_w        * setup new parameters
  157.     rts
  158. *****************************************************************
  159. * POP - opens a new window for editing
  160. pop:
  161.     bsr    get_buf        * get new buffer
  162.     rts
  163. *****************************************************************
  164. * ROTATE - pulls the bottom active screen to the top.
  165. rotate:
  166.     move.l    a5,a0        * get active screen
  167.     move.l    a5,a1        * prime "last good" pointer
  168. lp0_rt:
  169.     tst.l    (a0)        * is there another window?
  170.     beq    sk0_rt        * no, jump out
  171.     move.l    a0,a1        * save this pointer
  172.     move.l    (a0),a0        * get next window
  173.     bra    lp0_rt        * keep looping
  174. sk0_rt:
  175.     move.l    a5,(a0)        * link to former top window
  176.     move.l    a0,used        * move former bottom to root
  177.     move.l    a0,a5        * make former bottom active
  178.     clr.l    (a1)        * mark last window
  179.     bsr    border_w    * re-establish correct frame
  180.     rts
  181. *****************************************************************
  182. * REFRESH - redraws all screen buffers, leaves a5 set to top win.
  183. refresh:
  184.     bsr    cls        * get rid of stuff on the screen
  185.     clr.w    d1        * count the windows to open
  186.     move.l    #cmd_w,a5    * we have to reopen cmd window
  187.     bsr    open_w        * so we do.
  188.     move.l    used,a5        * get first active window address
  189. lp0_rf:
  190.     move.l    a5,-(a7)    * push a window address
  191.     beq    sk0_rf        * jump out if null
  192.     addq.w    #1,d1        * increment window count
  193.     move.l    (a5),a5        * get next window address
  194.     bra    lp0_rf        * and keep on doon it.
  195. sk0_rf:
  196.     addq.l    #4,a7        * pop null on top of stack
  197.     bra    sk1_rf        * do loop test before loop
  198. lp2_rf:
  199.     move.l    (a7)+,a5    * pop the window
  200.     bsr    open_w        * open the window
  201.     bsr    prtscr        * print the contents
  202. sk1_rf:
  203.     dbra    d1,lp2_rf
  204.     rts
  205.